package com.vf.admin.platform.service.impl;

import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.platform.dao.RoleDao;
import com.vf.admin.platform.dao.RoleMenuDao;
import com.vf.admin.platform.dao.RoleMenuElementDao;
import com.vf.admin.platform.dao.UserRoleDao;
import com.vf.admin.platform.entity.Role;
import com.vf.admin.platform.service.RoleService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class RoleServiceImpl implements RoleService {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    @Autowired
    private RoleDao roleDao;
    @Autowired
    private RoleMenuElementDao roleMenuElementDao;
    @Autowired
    private RoleMenuDao roleMenuDao;
    @Autowired
    private UserRoleDao userRoleDao;

    @Override
    public void saveOrUpdate(Role role) {
        roleDao.saveOrUpdate(role);
    }

    @Override
    public Role get(Integer id) {
        return roleDao.get(id);
    }

    @Override
    public List<Role> findList(Map<String, Object> paraMap, SplitPageBean splitPage) {
        return roleDao.findList(paraMap,splitPage);
    }

    @Override
    public void del(int id) {
        roleDao.del(id);
        userRoleDao.delByRoleId(id);
        roleMenuDao.delByRoleId(id);
        roleMenuElementDao.delByRoleId(id);
    }
}
